Skip to content

feat(ui): add keyboard shortcut hint to chat input#1408

Open
opspawn wants to merge 2 commits intokagent-dev:mainfrom
opspawn:feat/hotkey-submit-hint-v2
Open

feat(ui): add keyboard shortcut hint to chat input#1408
opspawn wants to merge 2 commits intokagent-dev:mainfrom
opspawn:feat/hotkey-submit-hint-v2

Conversation

@opspawn
Copy link
Contributor

@opspawn opspawn commented Feb 28, 2026

Summary

Adds a subtle text hint next to the Send button showing the keyboard shortcut to submit a message:

  • macOS: ⌘+Enter to send
  • Windows/Linux: Ctrl+Enter to send

The hint uses text-xs text-muted-foreground styling to stay unobtrusive, and is positioned to the left of the action buttons using mr-auto.

Implementation

  • Added useMemo hook with navigator.userAgent detection to determine OS
  • Single <span> element in the existing button row — no layout changes
  • Falls back to "Ctrl" for SSR (server-side rendering) compatibility

Closes #824

Signed-off-by: Sean Florez sean@opspawn.com


Migrated from #1402 (originally submitted from wrong fork)

Sean Florez and others added 2 commits February 28, 2026 00:31
Display a subtle "Ctrl+Enter to send" (or "⌘+Enter to send" on macOS)
hint next to the Send button so users discover the keyboard shortcut.

- OS-aware: detects macOS via navigator.userAgent and shows ⌘ symbol
- Uses muted foreground color and extra-small text to stay unobtrusive
- Positioned left of the action buttons with mr-auto for alignment

Closes kagent-dev#824

Signed-off-by: Sean Florez <sean@opspawn.com>
Replace useMemo with useState + useEffect to detect the OS-specific
shortcut key (⌘ vs Ctrl). The server always renders "Ctrl" as the
default, and the client updates to "⌘" on Mac after mount, avoiding
a server/client HTML mismatch.

Signed-off-by: fl-sean03 <fl.sean03@gmail.com>
@opspawn opspawn requested a review from peterj as a code owner February 28, 2026 20:07
Copilot AI review requested due to automatic review settings February 28, 2026 20:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an inline keyboard-shortcut hint next to the chat “Send” button to make the Ctrl/⌘+Enter submit behavior discoverable (closes #824).

Changes:

  • Detects platform to choose between Ctrl and for the hint.
  • Renders a subtle shortcut hint in the action row next to the Send button.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +77 to +82
const [shortcutKey, setShortcutKey] = useState("Ctrl");
useEffect(() => {
if (/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)) {
setShortcutKey("⌘");
}
}, []);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shortcut hint will render as "Ctrl" initially and then flip to "⌘" after mount on macOS, causing an avoidable extra render and a brief incorrect hint. Consider deriving the value in the useState lazy initializer (or a useMemo) so it’s correct on the first client render without needing setShortcutKey in an effect.

Suggested change
const [shortcutKey, setShortcutKey] = useState("Ctrl");
useEffect(() => {
if (/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)) {
setShortcutKey("⌘");
}
}, []);
const [shortcutKey] = useState(() =>
/Mac|iPhone|iPad|iPod/.test(
typeof navigator !== "undefined" ? navigator.userAgent : ""
)
? "⌘"
: "Ctrl"
);

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +82
const [shortcutKey, setShortcutKey] = useState("Ctrl");
useEffect(() => {
if (/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)) {
setShortcutKey("⌘");
}
}, []);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says this uses a useMemo hook for OS detection and mentions SSR fallback, but the code uses useState + useEffect (and this is a client component). Please update the PR description (or adjust the implementation) so reviewers/users aren’t misled about the approach and SSR behavior.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hint on the hotkey to submit the query to the agents in the UI

2 participants